#include <bits/stdc++.h>
// 2025/01/19
// tag: 
// Author: Zhang Muen
using namespace std;

string s;
int k;

signed main()
{
    cin >> s;
    cin >> k;   
    int cnt = s.size() - k, l = 0;
    bool flag = false;
    for (int i = 0; i < cnt; i++)
    {
        int m = INT_MAX, pos = 0;
        for (int j = l; j <= i + k; j++)
            if (s[j] - '0' < m)
                m = s[j] - '0', pos = j;
        if (m || cnt == 1 || flag)
            cout << m, flag = true;
        l = pos + 1;
    }
    return 0;
}